package com.tbryant.test.designpattern.zenofdesignpattern.builder.definition;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author TBryant
 * @date 2021/10/29 17:42
 */
public abstract class AbstractProduct {
    private List<String> sequence = Lists.newArrayList();

    protected abstract void doSomething1();

    protected abstract void doSomething2();

    protected abstract void doSomething3();

    final void run() {
        if (sequence.size() > 0) {
            for (String sequenceStr : sequence) {
                switch (sequenceStr) {
                    case "doSomething1":
                        this.doSomething1();
                        break;
                    case "doSomething2":
                        this.doSomething2();
                        break;
                    case "doSomething3":
                        this.doSomething3();
                        break;
                }
            }
        }
    }

    final void setSequence(List<String> sequence) {
        this.sequence = sequence;
    }
}
